#!usr/bin/env python
# -*- coding: utf-8 -*-
import frida

def on_message(message, data):
    for each in message['payload']:
        print(each)
    #print(message)
    #print(data)
    #print("[on_message] message:", message, "data:", data)
#processes = frida.get_remote_device().enumerate_processes()
#for process in processes:
#    print(process)

front_app = frida.get_remote_device().get_frontmost_application()
session = frida.get_remote_device().attach(front_app.pid)

jscode = """ 
Java.perform(function(){              
    var arr = Java.enumerateLoadedClassesSync();
     send(arr);  
  });  
"""

script = session.create_script(jscode)

script.on("message", on_message)
script.load()

